package com.lanxin.oa.zu.dao.daoImpl;

import com.lanxin.base.BaseDaoImpl;
import com.lanxin.bean.MpCardtype;
import com.lanxin.bean.MpContact;
import com.lanxin.oa.zu.dao.MingPianDao;
import com.lanxin.oa.zu.service.MingPianService;
import com.lanxin.util.PageBean;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class MingPianDaoImpl extends BaseDaoImpl implements MingPianDao {
    @Override
    public PageBean selectmp(Integer page, Integer pageSize, String name, String sex, String company, Integer typeid, String officePhone) {
        if(page==null){
            page=1;
        }
        if(pageSize==null){
            pageSize=5;
        }

        String hql="from MpContact mp left join fetch mp.type where 1=1";
        if(name !=null && !name.equals("")){
            hql = hql + "  and mp.name = '" + name + "'  ";
        }
        if(sex !=null && !sex.equals("")){
            hql = hql + "  and mp.sex = '" + sex + "'  ";
        }
        if(company !=null && !company.equals("")){
            hql = hql + "  and mp.company = '" + company + "'  ";
        }
        if(typeid !=null && !typeid.equals("")){
            hql = hql + "  and mp.typeid = '" + typeid + "'  ";
        }
        if(officePhone !=null && !officePhone.equals("")){
            hql = hql + "  and mp.officePhone = '" + officePhone + "'  ";
        }
        return super.pageFenYE(hql,page,pageSize);
    }

    @Override

    public List selectzu() {
        return super.queryAll("from MpCardtype");
    }

    @Override
    public MpContact selectmpByid(Integer oid) {
        return (MpContact) selectByHQL("from MpContact mp left join fetch mp.type where mp.oid="+oid);
    }
}
